﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data;
using Bussiness;
using Entities;

namespace Presentation
{
    public partial class frmChiPhiInAn : Form
    {
        private DataTable tbChiPhiInAn;
        private int macpinan;
        public frmChiPhiInAn()
        {
            InitializeComponent();
        }

        private void frmChiPhiInAn_Load(object sender, EventArgs e)
        {
            // DataTable ka = new DataTable();
            ChiPhiInAnBussiness cpbus = new ChiPhiInAnBussiness();
            this.tbChiPhiInAn = cpbus.danhsach();
            grdDanhSachChiPhiInAn.DataSource = this.tbChiPhiInAn;

        }

       


        private void grdDanhSachChiPhiInAn_SelectionChanged(object sender, EventArgs e)
        {
            this.txtTenSanPham.Text = grdDanhSachChiPhiInAn.CurrentRow.Cells["TenSP"].Value.ToString();
            this.txtChatLieu.Text = grdDanhSachChiPhiInAn.CurrentRow.Cells["TenChatLieu"].Value.ToString();
            this.txtChieuDai.Text = grdDanhSachChiPhiInAn.CurrentRow.Cells["ChieuDai"].Value.ToString();
            this.txtChieuRong.Text = grdDanhSachChiPhiInAn.CurrentRow.Cells["ChieuRong"].Value.ToString();
            this.txtMauSac.Text = grdDanhSachChiPhiInAn.CurrentRow.Cells["MauSac"].Value.ToString();
            this.macpinan = int.Parse(grdDanhSachChiPhiInAn.CurrentRow.Cells["Ma"].Value.ToString());
        }

        private void btnTim_Click_1(object sender, EventArgs e)
        {
            string tensp = txtTimTenSanPham.Text;

            ChiPhiInAnBussiness cpbus = new ChiPhiInAnBussiness();
            this.tbChiPhiInAn = cpbus.danhsach_spTheoTen(tensp);
            this.grdDanhSachChiPhiInAn.DataSource = this.tbChiPhiInAn;
        }

        private void btnCapNhat_Click(object sender, EventArgs e)
        {
            ChiPhiInAnEnt cp = new ChiPhiInAnEnt();
            cp.Dongia = int.Parse(this.txtDonGia.Text);
            cp.Machiphiinan = this.macpinan;
            ChiPhiInAnBussiness bus = new ChiPhiInAnBussiness();
            bus.capnhat(cp);
            MessageBox.Show("cập nhật thành công!");
        }

        private void btnLamLai_Click_1(object sender, EventArgs e)
        {
            this.txtDonGia.Text = "";
        }

        
    }
}
